package com.yubest.demo.anno.handler;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author hweiyu
 * @Description
 * @Date 2021/3/23 11:01
 */
public class HanlderChain {

    private List<Handler> handlers;

    public HanlderChain() {
        this.handlers = new ArrayList<>(10);
    }

    public HanlderChain register(Handler handler) {
        handlers.add(handler);
        return this;
    }

    public void execute(Context context) {
        for (Handler handler : handlers) {
            handler.execute(context);
        }
    }
}
